package com.health.controller.mobile;


import com.health.common.R;
import com.health.pojo.Setmeal;
import com.health.service.SetmealService;
import com.health.vo.SetmealDetailVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/mobile/setmeal")
@Slf4j
@RequiredArgsConstructor
@Api(tags = "移动端套餐管理")
public class MobileSetmealController {

    private final SetmealService setmealService;

    @ApiOperation(value = "查询所有套餐")
    @GetMapping("/list")
    public R getAllSetmeal() {
        log.info("查询所有套餐");
        List<Setmeal> setmealList = setmealService.query().list();
        return R.success(setmealList);
    }

    @GetMapping("/{id}")
    public R getSetmealDetailById(@PathVariable Integer id) {
        log.info("查询套餐详情 {}", id);
        SetmealDetailVO setmealDetailVO = setmealService.getSetmealDetailById(id);
        return R.success(setmealDetailVO);
    }

}
